package com.example.demo.mapper;

import com.example.demo.entity.Reservation;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ReservationMapper {
    @Insert("insert into reservations(username, type, number, date, time) values (#{username}, #{type}, #{number}, #{date}, #{time})")
    int addReservation(Reservation reservation);

    @Delete("delete from reservations where r_id=#{r_id}")
    int deleteReservation(int r_id);

    @Select("select * from reservations where username=#{username}")
    List<Reservation> findReservationByUsername(String username);
    @Select("select username from reservations where r_id=#{r_id}")
    String findUserByrid(int r_id);

    @Select("select r_id from reservations where number=#{number} and date=#{date} and time=#{time}")
    List<Integer> findReservationId(Reservation reservation);

    @Select("select * from reservations where type=#{type}")
    List<Reservation> findReservationByType(String type);
}
